package converter;

import com.gitee.feizns.dynamic.convert.ConvertUtils;
import lombok.Data;
import lombok.ToString;

/**
 * @author feizns
 * @since 2019/6/15 0015
 */
public class ConvertValueOfDemo {

    public static void main(String[] args) {

        User user = ConvertUtils.to(1, User.class);
        User userD = ConvertUtils.to(1.1d, User.class);

        System.out.println(user);   //ConvertValueOfDemo.Role(id=1)
        System.out.println(userD);   //ConvertValueOfDemo.Role(id=33)

    }

    @ToString
    @Data
    private static class User {

        private final Integer id;

        public User(Integer id) {
            this.id = id;
        }

        public static User from(int w) {
            return new User(w);
        }

        public static User from(Integer w) {
            return new User(w);
        }

        public static User from(Double w) {
            return new User((int) (w + 32));
        }

    }

}
